package com.richard.base.route

/**
 ***************************************
 * 项目名称:Giggle
 * @Author wuzhiguo
 * 邮箱：wuzhiguo@ksjgs.com
 * 创建时间: 2020/7/14     4:50 PM
 * 用途:
 ***************************************
 */


import androidx.annotation.Keep


@Keep
object RouterDelegate {

    private var config: RouterConfig? = null
    private var isInit: Boolean = false

    fun init(config: RouterConfig) {
        if (isInit) {
            return
        }
        RouterDelegate.config = config
        isInit = true
    }

    fun getCurrentActivityStatisticName(): String? {
        return checkConfig().getCurrentActivityStatisticName()
    }

    fun getCurrentActivityStatisticKey(): String? {
        return checkConfig().getCurrentActivityStatisticKey()
    }

    interface RouterConfig {
        fun getCurrentActivityStatisticKey(): String?
        fun getCurrentActivityStatisticName(): String?
    }


    fun checkConfig(): RouterConfig {
        if (config == null) {
            throw RuntimeException("请先调用 RouterDelegate.init(config: RouterConfig) 初始化路由代理")
        }

        return config!!
    }

}